﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ecommerceSample
{
    public partial class CategoryPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public String LimitWords(String Input, int Limit)
        {
            // split input string into words (max 21...last words go in last element)
            String[] Words = Input.Split(new char[] { ' ' }, Limit);

            // if we reach maximum words, replace last words with elipse
            if (Words.Length == Limit)
                Words[Limit - 1] = "...";
            else
                return Input;  // nothing to do

            // build new output string
            String Output = String.Join(" ", Words);
            return Output;
        }
    }
}